<include file='Common:header' />

<!-- /section:basics/navbar.layout -->
<div class="main-container" id="main-container">

	<!-- #section:basics/sidebar -->

	<include file='Common:left' />


	<!-- /section:basics/sidebar -->
	<div class="main-content">
		<div class="main-content-inner">
			<div class="page-content">


				<div class="col-xs-12 col-sm-12 rule-top alert alert-info top10">
					<button type="button" class="close" data-dismiss="alert">
						<i class="ace-icon fa fa-times"></i>
					</button>
					此处导入功能作为参考示例，缺少部分判断业务流程，程序员根据需求进行更改(参考：<a href="http://www.cnblogs.com/freespider/p/3284828.html" target="_blank">PHPEXCEL插件</a>)
				</div>

				<div class="row">
					<div class="col-xs-12">
						<form class="form-horizontal" name="excel_runimport" id="excel_runimport" method="post" action="{:U('excel_runimport')}"  enctype="multipart/form-data">
							<div class="form-group">
								<label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 【文章】选择上传的EXCEL文件： </label>
								<div class="col-sm-4">
									<a href="javascript:;" class="file">
										<input type="file" name="file_stu" id="file_stu"  class="file" multiple="multiple"/>
										选择上传文件
									</a>
												<span class="input-group-btn" style="float:inherit; left:140px; top:2px;">
													<button type="submit" class="btn btn-xs  btn-purple">
														<span class="ace-icon fa fa-search icon-on-right bigger-110"></span>
														表格导入
													</button>
												</span>
									<span style="float:right; line-height:35px; top:2px;"><a href="__PUBLIC__/Excel/sample/mr_news.xls" target="_blank">下载示例表格</a></span>

								</div>

							</div>
							<div class="space-4"></div>
						</form>
					</div>
				</div>
				<div class="hr hr-24"></div>

				<include file='Common:header_nav' />

			</div><!-- /.page-content -->
		</div>
	</div><!-- /.main-content -->


	<script>

		$(function(){

			$('#excel_runimport').ajaxForm({
				beforeSubmit: checkForm,
				success: complete,
				dataType: 'json'
			});

			function checkForm(){
				if( '' == $.trim($('#file_stu').val())){
					layer.alert('上传文件不能为空不能为空', {icon: 5}, function(index){
						layer.close(index);
						$('#file_stu').focus();
					});
					return false;
				}
			}
			function complete(data){
				if(data.status==1){
					layer.alert(data.info, {icon: 6}, function(index){
						layer.close(index);
						window.location.href=data.url;
						return false;
					});
				}else{
					layer.alert(data.info, {icon: 5}, function(index){
						layer.close(index);
						window.location.href="{:U('excel_import')}";
						return false;
					});
				}
			}
		});
	</script>
	<include file='Common:footer' />


	</body>
	</html>
